﻿using System;
using System.Collections.Generic;

using EnvDTE;
using EnvDTE80;
using VSLangProj;

namespace Antix.VSAddIn
{
    public static class Extensions
    {
        /// <summary>
        /// <para>Check for reference by name</para>
        /// </summary>
        public static bool HasReference(this Project project, string referenceName)
        {
            VSProject vsProject = (VSProject)project.Object;
            foreach (Reference reference in vsProject.References)
            {
                if (reference.Name == referenceName) { return true; }
            }

            return false;
        }

        /// <summary>
        /// <para>Add a reference given a path</para>
        /// </summary>
        public static void AddReference(this Project project, string referencePath)
        {
            ((VSProject)project.Object).References.Add(referencePath);
        }
    }
}
